home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / Buttons / LAGAPushButton.cp < prev    next >
Encoding:
Text File  |  1996-06-30  |  17.7 KB  |  548 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LAGAPushButton.cp
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant (almost) Push Button
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGAPushButton.h            <- double-click + Command-D to see class declaration
  27. //
  28. //    LAGAPushButton is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        Push Buttons with the exception of the pressed state. The pressed state is my own kind,
  30. //        because I (and my customers) found it nicer than Apple's ;-)
  31. //
  32. //        if mRadioBehavior is set, the Push Button acts as a RadioButton and can be used with
  33. //        a radio group
  34. //
  35. //        This class requires AGAColors.cp to be present in your project
  36. //
  37. //        Version : 1.2
  38. //
  39. //        Change History (most recent first, date in US form : mm/dd/yy):
  40. //
  41. //                        06/30/96    ca        Public release of version 1.2
  42. //                        06/27/96    ca        Changed checks for disabled state (check on triState_On instead of triState_Off)
  43. //                                                            in order that triState_Latent state is drawn as disabled
  44. //                        06/04/96    ca        Added static RegisterClass for easier class registration
  45. //                                                        made changes to allow the usage of either the standard button template or the custom LAGAPushButton
  46. //                                                            template. The standard button template is easier for layout because you can see the text, but you
  47. //                                                            can't control the checkbox behavior of the button, which is possible from the custom template
  48. //                                                        Defined class_ID1 and CreateAGAPushButtonStream1 to handle the two template possibilities
  49. //                                                        Added a CPPb to "LAGAPushButton CPPb.rsrc" called LAGAPushButton1 to handle the standard button
  50. //                                                            template, without having to tinker the class ID
  51. //                                                        Increased version to 1.2
  52. //                        06/01/96    ms        Changes brought by Marco Sandri <msandri@mbox.vol.it>
  53. //                                                        Changes made to avoid icon "flicker" during pressing
  54. //                        05/15/96    ca        Increased version to 1.1
  55. //                                                        Replaced mTextTraitsH by mTextTraitsID, to simplify, text traits management
  56. //                                                        Replaced UEnvironment::HasFeature(env_SupportsColor) with PaneInColor
  57. //                                                        Added copy constructor
  58. //                                                        Added "on the fly" constructor
  59. //                                                        Added change history
  60. //                        04/??/96    jhs        Improvements sent by James H. Stein <steinj@best.com>
  61. //                                                        Added missing includes (for those who do not use the "classic" PP prefix)
  62. //                                                        Added adjustement for italics
  63. //                                                        Added frame adjustment if the font is the text is higher than the button
  64. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  65. //                                                        (version 1.0)
  66. //
  67. //        To Do:
  68. //
  69.  
  70. #include "LAGAPushButton.h"
  71. #include "AGAColors.h"
  72. #include <UDrawingState.h>
  73. #include <UDrawingUtils.h>
  74. #include <PP_Messages.h>
  75. #include <PP_Resources.h>
  76.  
  77. char LAGAPushButton::mCorners[3][4][4][4] =    {
  78.                                                                                             //    Enabled
  79.                                                                                             {
  80.                                                                                                 //    topleft
  81.                                                                                                 {
  82.                                                                                                     { -1, -1, 12,  B },
  83.                                                                                                     { -1,  B,  4,  2 },
  84.                                                                                                     { 12,  4,  W,  W },
  85.                                                                                                     {  B,  2,  W,  W }
  86.                                                                                                 },
  87.                                                                                                 //    topright
  88.                                                                                                 {
  89.                                                                                                     {  B, 12, -1, -1 },
  90.                                                                                                     {  2,  4,  B, -1 },
  91.                                                                                                     {  W,  2,  5, 12 },
  92.                                                                                                     {  2,  5,  8,  B }
  93.                                                                                                 },
  94.                                                                                                 //    bottomleft
  95.                                                                                                 {
  96.                                                                                                     {  B,  2,  W,  2 },
  97.                                                                                                     { 12,  4,  2,  5 },
  98.                                                                                                     { -1,  B,  4,  8 },
  99.                                                                                                     { -1, -1, 12,  B }
  100.                                                                                                 },
  101.                                                                                                 //    bottomright
  102.                                                                                                 {
  103.                                                                                                     {  5,  5,  8,  B },
  104.                                                                                                     {  5,  8,  8, 12 },
  105.                                                                                                     {  8,  8,  B, -1 },
  106.                                                                                                     {  B, 12, -1, -1 }
  107.                                                                                                 }
  108.                                                                                             },
  109.                                                                                             //    Pressed
  110.                                                                                             {
  111.                                                                                                 //    topleft
  112.                                                                                                 {
  113.                                                                                                     { -1, -1, 12,  B },
  114.                                                                                                     { -1,  B, 10,  8 },
  115.                                                                                                     { 12, 10,  8,  4 },
  116.                                                                                                     {  B,  8,  4,  4 }
  117.                                                                                                 },
  118.                                                                                                 //    topright
  119.                                                                                                 {
  120.                                                                                                     {  B, 12, -1, -1 },
  121.                                                                                                     {  8, 10,  B, -1 },
  122.                                                                                                     {  4,  4,  8, 12 },
  123.                                                                                                     {  4,  4,  4,  B }
  124.                                                                                                 },
  125.                                                                                                 //    bottomleft
  126.                                                                                                 {
  127.                                                                                                     {  B,  8,  4,  4 },
  128.                                                                                                     { 12, 10,  4,  4 },
  129.                                                                                                     { -1,  B, 10,  4 },
  130.                                                                                                     { -1, -1, 12,  B }
  131.                                                                                                 },
  132.                                                                                                 //    bottomright
  133.                                                                                                 {
  134.                                                                                                     {  4,  4,  4,  B },
  135.                                                                                                     {  4,  4, 10, 12 },
  136.                                                                                                     {  4, 10,  B, -1 },
  137.                                                                                                     {  B, 12, -1, -1 }
  138.                                                                                                 }
  139.                                                                                             },
  140.                                                                                             //    Disabled
  141.                                                                                             {
  142.                                                                                                 //    topleft
  143.                                                                                                 {
  144.                                                                                                     { -1, -1,  7,  7 },
  145.                                                                                                     { -1,  7,  4,  2 },
  146.                                                                                                     {  7,  4,  1,  1 },
  147.                                                                                                     {  7,  2,  1,  1 }
  148.                                                                                                 },
  149.                                                                                                 //    topright
  150.                                                                                                 {
  151.                                                                                                     {  7,  7, -1, -1 },
  152.                                                                                                     {  2,  4,  7, -1 },
  153.                                                                                                     {  1,  2,  4,  7 },
  154.                                                                                                     {  2,  4,  5,  7 }
  155.                                                                                                 },
  156.                                                                                                 //    bottomleft
  157.                                                                                                 {
  158.                                                                                                     {  7,  2,  1,  2 },
  159.                                                                                                     {  7,  4,  2,  4 },
  160.                                                                                                     { -1,  7,  4,  5 },
  161.                                                                                                     { -1, -1,  7,  7 }
  162.                                                                                                 },
  163.                                                                                                 //    bottomright
  164.                                                                                                 {
  165.                                                                                                     {  4,  4,  5,  7 },
  166.                                                                                                     {  4,  5,  5,  7 },
  167.                                                                                                     {  5,  5,  7, -1 },
  168.                                                                                                     {  7,  7, -1, -1 }
  169.                                                                                                 }
  170.                                                                                             }
  171.                                                                                         };
  172.                                                                                         
  173. // begin <06/04/96 ca>
  174. void LAGAPushButton::RegisterClass ()
  175.  
  176. {
  177.     URegistrar::RegisterClass(LAGAPushButton::class_ID, (ClassCreatorFunc)LAGAPushButton::CreateAGAPushButtonStream);
  178.     URegistrar::RegisterClass(LAGAPushButton::class_ID1, (ClassCreatorFunc)LAGAPushButton::CreateAGAPushButtonStream1);
  179. }
  180. // end <06/04/96 ca>
  181.  
  182. LAGAPushButton* LAGAPushButton::CreateAGAPushButtonStream (LStream *inStream)
  183.  
  184. {
  185.     //    Constructing from a 'AGA7' template
  186.     return(new LAGAPushButton(inStream));
  187. }
  188.  
  189. LAGAPushButton* LAGAPushButton::CreateAGAPushButtonStream1 (LStream *inStream)
  190.  
  191. {
  192.     //    Constructing from a 'AgA7' template
  193.     return(new LAGAPushButton(inStream, true));
  194. }
  195.  
  196. //-------Constructors-------------------------------------------------------------------------------------------------
  197.  
  198. LAGAPushButton::LAGAPushButton ()
  199.  
  200. {
  201.     mTextTraitsID = Txtr_SystemFont;                                                                                                                //    <05/15/96    ca>
  202.     mStyleCache = -1;                                                                                                                                                //    <05/15/96    ca>
  203.     mRadioBehavior = false;
  204. }
  205.  
  206. LAGAPushButton::LAGAPushButton (LStream    *inStream, Boolean inCreateWithStandardButton) : LControl(inStream)
  207.  
  208. {
  209.     mStyleCache = -1;                                                                                                                                                //    <05/15/96    ca>
  210.  
  211.     if (inCreateWithStandardButton)
  212.         {
  213.             //    begin <06/04/96    ca>
  214.             // Change so we can use the standard button template; makes layout easier
  215.             Int16    controlKind;
  216.             ResIDT    textTraitsID;
  217.             Str255    title;
  218.             Int32    macRefCon;
  219.             
  220.             inStream->ReadData(&controlKind, sizeof(Int16));            //    Ignored
  221.             inStream->ReadData(&mTextTraitsID, sizeof(ResIDT));
  222.             inStream->ReadPString(mTitle);
  223.             inStream->ReadData(&macRefCon, sizeof(Int32));                //    Ignored
  224.             mRadioBehavior = false;
  225.             //    end <06/04/96    ca>
  226.         }
  227.     else
  228.         {
  229.             unsigned char radioBehavior;
  230.             
  231.             inStream->ReadPString(mTitle);
  232.             
  233.             inStream->ReadData(&mTextTraitsID, sizeof (ResIDT));                                                                        //    <05/15/96    ca>
  234.  
  235.             inStream->ReadData(&radioBehavior, sizeof(unsigned char));
  236.             mRadioBehavior = (radioBehavior != 0);
  237.             if (mRadioBehavior)
  238.                 mMaxValue = 1;
  239.         }
  240. }
  241.  
  242. //    begin <05/15/96 ca>
  243. LAGAPushButton::LAGAPushButton (const LAGAPushButton &inOriginal) : LControl(inOriginal)
  244.  
  245. {
  246.     mTitle = inOriginal.mTitle;
  247.     mTextTraitsID = inOriginal.mTextTraitsID;
  248.     mStyleCache = inOriginal.mStyleCache;
  249.     mRadioBehavior = inOriginal.mRadioBehavior;
  250.     if (mRadioBehavior)
  251.         mMaxValue = 1;
  252. }
  253.  
  254. LAGAPushButton::LAGAPushButton (const SPaneInfo &inPaneInfo, MessageT inClickedMessage, ResIDT inTextTraitsID,
  255.                                                                 Str255 inTitle, Boolean inRadioButtonBehavior) : LControl(inPaneInfo, inClickedMessage, 0, 0, 1)
  256. {
  257.     mTitle = inTitle;
  258.     mTextTraitsID = inTextTraitsID;
  259.     mStyleCache = -1;
  260.     mRadioBehavior = inRadioButtonBehavior;
  261.     if (mRadioBehavior)
  262.         mMaxValue = 1;
  263. }
  264. //    end <05/15/96 ca>
  265.  
  266. //-------Utilities--------------------------------------------------------------------------------------------------
  267.  
  268. void LAGAPushButton::HotSpotResult (Int16    inHotSpot)
  269.  
  270. {
  271.                                                             // Undo Button hilighting
  272.     if (!mRadioBehavior)
  273.         {
  274.             HotSpotAction(inHotSpot, false, true);
  275.             BroadcastValueMessage();        // Although value doesn't change,
  276.                                                                     //   send message to inform Listeners
  277.                                                                     //   that button was clicked
  278.         }
  279.     else
  280.         {
  281.             // In the Mac interface, clicking on a RadioButton always
  282.             // turns it on (or leaves it on). The standard way to turn
  283.             // off a RadioButton is to turn on another one in the
  284.             // same Radio Group. A Radio Group will normally be a
  285.             // Listener of a RadioButton.
  286.          
  287.             if (mValue != Button_On)                                                                                                                                                        //    <06/01/96    ms>
  288.                 SetValue(Button_On);
  289.         }
  290. }
  291.  
  292. void LAGAPushButton::HotSpotAction (Int16 inHotSpot, Boolean inCurrInside, Boolean inPrevInside)
  293.  
  294. {
  295.                                     // Draw if cursor moved from IN to OUT
  296.                                     //   or from OUT to IN
  297.     if (inCurrInside != inPrevInside && (!mRadioBehavior || mValue != Button_On))                                                        //    <06/01/96    ms>
  298.         {    
  299.             FocusDraw();
  300.             DrawAll(inCurrInside);
  301.         }
  302. }
  303.  
  304. void LAGAPushButton::SetValue (Int32    inValue)
  305.  
  306. {
  307.     
  308.     if (!mRadioBehavior)
  309.         {
  310.             LControl::SetValue(inValue);
  311.         }
  312.     else
  313.         {
  314.             if (inValue < mMinValue)
  315.                 inValue = mMinValue;
  316.             else
  317.                 if (inValue > mMaxValue)
  318.                     inValue = mMaxValue;
  319.             mValue = inValue;
  320.             // If turning RadioButton on, broadcast message so that the
  321.             // RadioGroup (if present) will turn off the other RadioButtons
  322.             // in the group.
  323.     
  324.             if (inValue == Button_On)
  325.                 {
  326.                     BroadcastValueMessage();
  327.                     BroadcastMessage(msg_ControlClicked, (void*) this);
  328.                 }
  329.             Draw(nil);                                                                                                                                                                                //    <06/01/96    ms>
  330.         }
  331. }
  332.  
  333. StringPtr LAGAPushButton::GetDescriptor (Str255 outDescriptor) const
  334.  
  335. {
  336.     return LString::CopyPStr(mTitle, outDescriptor);
  337. }
  338.  
  339. void LAGAPushButton::SetDescriptor (ConstStr255Param inDescriptor)
  340.  
  341. {
  342.     mTitle = inDescriptor;
  343.     Refresh();
  344. }
  345.  
  346. //-------Drawers----------------------------------------------------------------------------------------------------
  347.  
  348. void LAGAPushButton::DrawSelf ()
  349.  
  350. {
  351.     DrawAll(false);
  352. }
  353.  
  354. void LAGAPushButton::DrawAll (Boolean inPushed)
  355.  
  356. {
  357.     DrawGraphic(inPushed);
  358.     DrawText(inPushed);
  359. }
  360.  
  361. void LAGAPushButton::DrawGraphic (Boolean inPushed)
  362.  
  363. {
  364.     StColorPenState theState;
  365.     Rect frame, tempRect;
  366.     long theValue = (mRadioBehavior ? mValue : 0);
  367.     Boolean down = inPushed || (theValue != 0);
  368.     Boolean hasColor = ::PaneInColor(this);
  369.     Boolean disabled = (mEnabled != triState_On);                                                            //    <06/27/96    ca>
  370.  
  371.     theState.Normalize();
  372.     CalcLocalFrameRect(frame);
  373.     
  374.     tempRect = frame;
  375.     ::InsetRect(&tempRect, 1, 1);
  376.     if (hasColor)
  377.         {
  378.             ApplyForeAndBackColors();
  379.             if (down)
  380.                 ::RGBBackColor(&gAGAColorArray[4]);
  381.         }
  382.     EraseRect(&tempRect);
  383.     
  384.     //    Draw the frame;
  385.     if (disabled)
  386.         {
  387.             if (hasColor)
  388.                 ::RGBForeColor(&gAGAColorArray[7]);
  389.             else
  390.                 ::PenPat(&qd.gray);
  391.         }
  392.     ::MoveTo(frame.left + 2, frame.top);
  393.     ::LineTo(frame.right - 3, frame.top);
  394.     ::LineTo(frame.right - 1, frame.top + 2);
  395.     ::LineTo(frame.right - 1, frame.bottom - 3);
  396.     ::LineTo(frame.right - 3, frame.bottom - 1);
  397.     ::LineTo(frame.left + 2, frame.bottom - 1);
  398.     ::LineTo(frame.left, frame.bottom - 3);
  399.     ::LineTo(frame.left, frame.top + 2);
  400.     ::LineTo(frame.left + 2, frame.top);
  401.     if (disabled && !hasColor)
  402.         ::PenNormal();
  403.     
  404.     //    Draw the four corners around
  405.     if (hasColor)
  406.         {
  407.             short pattern = (disabled ? 2 : (down ? 1 : 0));
  408.             const RGBColor *col = gAGAColorArray;
  409.             for (int i = 0; i < 4; i++)
  410.                 for (int j = 0; j < 4; j++)
  411.                     {
  412.                         if (mCorners[pattern][0][i][j] != -1)
  413.                             ::SetCPixel(frame.left + j, frame.top + i, &col[mCorners[pattern][0][i][j]]);
  414.                         if (mCorners[pattern][1][i][j] != -1)
  415.                             ::SetCPixel(frame.right - 4 + j, frame.top + i, &col[mCorners[pattern][1][i][j]]);
  416.                         if (mCorners[pattern][2][i][j] != -1)
  417.                             ::SetCPixel(frame.left + j, frame.bottom - 4 + i, &col[mCorners[pattern][2][i][j]]);
  418.                         if (mCorners[pattern][3][i][j] != -1)
  419.                             ::SetCPixel(frame.right - 4 + j, frame.bottom - 4 + i, &col[mCorners[pattern][3][i][j]]);
  420.                     }
  421.             
  422.             if (down)
  423.                 ::RGBForeColor(&gAGAColorArray[8]);
  424.             else
  425.                 ::RGBForeColor(&gAGAColorArray[2]);
  426.             ::MoveTo(frame.left + 1, frame.top + 4);
  427.             ::LineTo(frame.left + 1, frame.bottom - 5);
  428.             ::MoveTo(frame.left + 4, frame.top + 1);
  429.             ::LineTo(frame.right - 5, frame.top + 1);
  430.             
  431.             if (!down)
  432.                 {
  433.                     if (disabled)
  434.                         ::RGBForeColor(&gAGAColorArray[1]);
  435.                     else
  436.                         ::ForeColor(whiteColor);
  437.                     ::MoveTo(frame.left + 2, frame.bottom - 5);
  438.                     ::LineTo(frame.left + 2, frame.top + 2);
  439.                     ::LineTo(frame.right - 5, frame.top + 2);
  440.             
  441.                     if (disabled)
  442.                         ::RGBForeColor(&gAGAColorArray[5]);
  443.                     else
  444.                         ::RGBForeColor(&gAGAColorArray[8]);
  445.                     ::MoveTo(frame.left + 4, frame.bottom - 2);
  446.                     ::LineTo(frame.right - 5, frame.bottom - 2);
  447.                     ::MoveTo(frame.right - 2, frame.bottom - 5);
  448.                     ::LineTo(frame.right - 2, frame.top + 4);
  449.                     
  450.                     if (disabled)
  451.                         ::RGBForeColor(&gAGAColorArray[4]);
  452.                     else
  453.                         ::RGBForeColor(&gAGAColorArray[5]);
  454.                     ::MoveTo(frame.left + 4, frame.bottom - 3);
  455.                     ::LineTo(frame.right - 5, frame.bottom - 3);
  456.                     ::MoveTo(frame.right - 3, frame.bottom - 5);
  457.                     ::LineTo(frame.right - 3, frame.top + 4);
  458.                 }
  459.         }
  460. }
  461.  
  462. void LAGAPushButton::DrawText (Boolean inPushed)
  463.  
  464. {
  465.     StTextState origTextState;
  466.     StColorPenState origCPenState;
  467.     Boolean hasColor = ::PaneInColor(this);
  468.     
  469.     Rect theFrame;
  470.     CalcLocalFrameRect(theFrame);
  471.     ::InsetRect(&theFrame, 3, 3);
  472.     //StClipRgnState theClip(theFrame);        //    There is no need to clip here, since in UTextDrawing::DrawWithJustification
  473.                                                                                 //    clipping is already handled
  474.  
  475.     Int16 theJust = UTextTraits::SetPortTextTraits(mTextTraitsID);                                                        //    <05/15/96    ca>
  476.     short theWidth = ::StringWidth(mTitle);
  477.     {
  478.         //    <04/??/96    jhs>    Italic adjustment    <05/15/96    ca>
  479.         if (mStyleCache == -1)
  480.             {
  481.                 //    The style is not known, let's get it
  482.                 TextTraitsH theTraitH = UTextTraits::LoadTextTraits(mTextTraitsID);
  483.                 mStyleCache = (theTraitH ? (*theTraitH)->style : 0);
  484.             }
  485.         Boolean isItalic = mStyleCache & (1 << italicBit);
  486.         if (isItalic)
  487.             theWidth += 5;
  488.     }
  489.     //    Center horizontally
  490.     if (theWidth < (theFrame.right - theFrame.left))
  491.         {
  492.             theFrame.left = (((theFrame.right - theFrame.left) - theWidth) / 2) + theFrame.left;
  493.             theFrame.right = theFrame.left + theWidth + 1;
  494.         }
  495.     
  496.     //    Center vertically
  497.     FontInfo    fontInfo;
  498.     ::GetFontInfo(&fontInfo);
  499.     short lineHeight = fontInfo.ascent + fontInfo.descent;
  500.     if (lineHeight < (theFrame.bottom - theFrame.top))
  501.         theFrame.top = (((theFrame.bottom - theFrame.top) - lineHeight) / 2) + theFrame.top;
  502.     theFrame.top -= 2;
  503.     {
  504.         //    <04/??/96    jhs> klutzes in:
  505.         while (lineHeight > theFrame.bottom - theFrame.top)
  506.             {
  507.                 ++theFrame.bottom;
  508.                 --theFrame.top;
  509.             }
  510.     }
  511.     
  512.     long theValue = (mRadioBehavior ? mValue : 0);
  513.     if (hasColor)
  514.         {
  515.             if (inPushed || (theValue != 0))
  516.                 {
  517.                     theFrame.left++;
  518.                     theFrame.right++;
  519.                     theFrame.top++;
  520.                     theFrame.bottom++;
  521.                 }
  522.             // Set background color
  523.         
  524.             RGBColor    textColor;            // Text has its own foreground color
  525.             ::GetForeColor(&textColor);
  526.             
  527.             ApplyForeAndBackColors();
  528.             if (mEnabled == triState_On)                                                                                                                                    //    <06/27/96    ca>
  529.                 {
  530.                     ::RGBForeColor(&textColor);
  531.                     if (inPushed)
  532.                         ::RGBBackColor(&gAGAColorArray[4]);
  533.                 }
  534.             else
  535.                 ::RGBForeColor(&gAGAColorArray[7]);
  536.         }
  537.     
  538.     UTextDrawing::DrawWithJustification((Ptr)&mTitle[1], mTitle[0], theFrame, theJust);
  539.     
  540.     if (!hasColor && (inPushed || (theValue != 0)))
  541.         {
  542.             CalcLocalFrameRect(theFrame);
  543.             ::InsetRect(&theFrame, 1, 1);
  544.             ::InvertRect(&theFrame);
  545.         }
  546. }
  547.  
  548.